diff options
author | jstebbins <[email protected]> | 2011-06-03 21:56:10 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-06-03 21:56:10 +0000 |
commit | 769ae8079fb560e598babf54e20eefca332b37d5 (patch) | |
tree | c7689e07101982244ece2a2c7dec0cb0074b5360 | |
parent | 3a6f545a6bd88001c994383b32e9560000111899 (diff) |
LinGui: Add support for naming audio tracks.
Also fix hb_audio_add. It was not copying the audio name.
And fix audio track name parsing in the CLI.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4020 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | gtk/src/audiohandler.c | 9 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 63 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 12 | ||||
-rw-r--r-- | gtk/src/internal_defaults.xml | 2 | ||||
-rw-r--r-- | libhb/common.c | 4 | ||||
-rw-r--r-- | test/test.c | 37 |
6 files changed, 92 insertions, 35 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 0e809ebcb..f6dfbf19e 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -572,7 +572,7 @@ G_MODULE_EXPORT gchar* format_gain_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud) { if ( val >= 21.0 ) - return g_strdup_printf("*11*", (int)val); + return g_strdup_printf("*11*"); return g_strdup_printf("%ddB", (int)val); } @@ -701,6 +701,7 @@ audio_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t ghb_settings_set_value(ud->settings, "AudioEncoderActual", ghb_settings_get_value(asettings, "AudioEncoderActual")); ghb_check_dependency(ud, NULL, "AudioEncoderActual"); ghb_ui_update(ud, "AudioBitrate", ghb_settings_get_value(asettings, "AudioBitrate")); + ghb_ui_update(ud, "AudioTrackName", ghb_settings_get_value(asettings, "AudioTrackName")); ghb_ui_update(ud, "AudioSamplerate", ghb_settings_get_value(asettings, "AudioSamplerate")); ghb_ui_update(ud, "AudioMixdown", ghb_settings_get_value(asettings, "AudioMixdown")); ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_settings_get_value(asettings, "AudioTrackDRCSlider")); @@ -726,6 +727,12 @@ ghb_add_audio(signal_user_data_t *ud, GValue *settings) track = ghb_settings_combo_option(settings, "AudioTrack"); ghb_settings_set_string(settings, "AudioTrackDescription", track); + GValue *aname; + aname = ghb_dict_lookup(settings, "AudioTrackName"); + if (aname == NULL) + { + ghb_settings_set_string(settings, "AudioTrackName", ""); + } audio_list = ghb_settings_get_value(ud->settings, "audio_list"); if (audio_list == NULL) { diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 7c61f92e1..729880e15 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -3869,14 +3869,14 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> <object class="GtkTable" id="table14"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="n_rows">3</property> + <property name="n_rows">4</property> <property name="n_columns">3</property> <property name="row_spacing">5</property> <child> - <object class="GtkLabel" id="sr_label"> + <object class="GtkLabel" id="audio_name_label"> <property name="visible">True</property> <property name="xalign">1</property> - <property name="label" translatable="yes">Sample Rate:</property> + <property name="label" translatable="yes">Audio Track Name:</property> <property name="use_markup">True</property> </object> <packing> @@ -3888,16 +3888,51 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> </packing> </child> <child> - <object class="GtkComboBox" id="AudioSamplerate"> + <object class="GtkEntry" id="AudioTrackName"> <property name="visible">True</property> + <property name="can_focus">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip-text" translatable="yes">Set the sample rate of the output audio track.</property> + <property name="max_length">40</property> + <property name="activates_default">True</property> + <property name="width_chars">30</property> + <property name="truncate_multiline">True</property> + <property name="tooltip-text" translatable="yes">Set the audio track name. Players may use this in the audio selection list.</property> <signal handler="audio_widget_changed_cb" name="changed"/> </object> <packing> <property name="top_attach">0</property> <property name="bottom_attach">1</property> - <property name="left_attach">2</property> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="x_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="sr_label"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Sample Rate:</property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="x_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="AudioSamplerate"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Set the sample rate of the output audio track.</property> + <signal handler="audio_widget_changed_cb" name="changed"/> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="left_attach">1</property> <property name="right_attach">2</property> <property name="x_options">GTK_FILL</property> </packing> @@ -3910,8 +3945,8 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> <property name="use_markup">True</property> </object> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> <property name="left_attach">0</property> <property name="right_attach">1</property> <property name="x_options">GTK_FILL</property> @@ -3930,8 +3965,8 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> <signal name="format_value" handler="format_gain_cb"/> </object> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> <property name="left_attach">1</property> <property name="right_attach">3</property> <property name="x_options">GTK_FILL|GTK_EXPAND</property> @@ -3945,8 +3980,8 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> <property name="use_markup">True</property> </object> <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> <property name="left_attach">0</property> <property name="right_attach">1</property> <property name="x_options">GTK_FILL</property> @@ -3967,8 +4002,8 @@ For source audio that has a wide dynamic range (very loud and very soft sequence <signal name="format_value" handler="format_drc_cb"/> </object> <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> <property name="left_attach">1</property> <property name="right_attach">3</property> <property name="x_options">GTK_FILL|GTK_EXPAND</property> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 2d17a7c32..39c8cbd70 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -4698,6 +4698,18 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) audio.in.track = ghb_settings_get_int(asettings, "AudioTrack"); audio.out.track = tcount; + char * aname = ghb_settings_get_string(asettings, "AudioTrackName"); + if (aname && *aname) + { + // This leaks, but there is no easy way to clean up + // presently + audio.out.name = aname; + } + else + { + g_free(aname); + } + aconfig = (hb_audio_config_t *) hb_list_audio_config_item( title->list_audio, audio.in.track ); diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index c4792efa3..e4a4a72b6 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -4,6 +4,8 @@ <dict> <key>Initialization</key> <dict> + <key>AudioTrackName</key> + <string></string> <key>AudioEncoderActual</key> <string></string> <key>angle_count</key> diff --git a/libhb/common.c b/libhb/common.c index 731409e2b..868cafbcb 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -1228,6 +1228,10 @@ int hb_audio_add(const hb_job_t * job, const hb_audio_config_t * audiocfg) audio->config.out.mixdown = audiocfg->out.mixdown; audio->config.out.gain = audiocfg->out.gain; } + if (audiocfg->out.name && *audiocfg->out.name) + { + audio->config.out.name = audiocfg->out.name; + } hb_list_add(job->list_audio, audio); return 1; diff --git a/test/test.c b/test/test.c index e1f2bc29a..7e5112e36 100644 --- a/test/test.c +++ b/test/test.c @@ -72,7 +72,7 @@ static char * atracks = NULL; static char * arates = NULL; static char * abitrates = NULL; static char * acodecs = NULL; -static char * anames = NULL; +static char ** anames = NULL; #ifdef __APPLE_CC__ static int default_acodec = HB_ACODEC_CA_AAC; #else @@ -351,7 +351,6 @@ int main( int argc, char ** argv ) if( arates ) free( arates ); if( abitrates ) free( abitrates ); if( acodecs ) free( acodecs ); - if( anames ) free( anames ); if (native_language ) free (native_language ); if( advanced_opts ) free (advanced_opts ); if( advanced_opts2 ) free (advanced_opts2 ); @@ -1893,27 +1892,25 @@ static int HandleEvents( hb_handle_t * h ) /* Audio Gain */ /* Audio Track Names */ - i = 0; if ( anames ) { - char * token = strtok(anames, ","); - if (token == NULL) - token = anames; - while ( token != NULL ) + char * token; + for ( i = 0; anames[i] != NULL && i < num_audio_tracks; i++ ) { - audio = hb_list_audio_config_item(job->list_audio, i); - if( audio != NULL ) - { - audio->out.name = strdup(token); - if( (++i) >= num_audio_tracks ) - break; /* We have more names than audio tracks, oops */ - } - else + token = anames[i]; + if ( *token ) { - fprintf(stderr, "Ignoring aname '%s', no audio track\n", - token); + audio = hb_list_audio_config_item(job->list_audio, i); + if( audio != NULL ) + { + audio->out.name = strdup(token); + } + else + { + fprintf(stderr, "Ignoring aname '%s', no audio track\n", + token); + } } - token = strtok(NULL, ","); } } if( i < num_audio_tracks && i == 1 ) @@ -1923,7 +1920,7 @@ static int HandleEvents( hb_handle_t * h ) for ( ; i < num_audio_tracks; i++) { audio = hb_list_audio_config_item(job->list_audio, i); - audio->out.name = strdup(anames); + audio->out.name = strdup(anames[0]); } } /* Audio Track Names */ @@ -3305,7 +3302,7 @@ static int ParseOptions( int argc, char ** argv ) case 'A': if( optarg != NULL ) { - anames = strdup( optarg ); + anames = str_split( optarg, ',' ); } break; case PREVIEWS: |