Skip to content

Commit

Permalink
Messages for client about connecting/prebuffering.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.daper.net/moc/trunk@1094 910807d9-36e0-0310-a014-e9ea483e2ba4
  • Loading branch information
daper committed Feb 27, 2005
1 parent 3c25e7e commit a978689
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,18 @@ static void *play_thread (void *unused ATTR_UNUSED)
struct io_stream *stream = NULL;

if (file_type(file) == F_URL) {
status_msg ("Connecting...");
stream = io_open (file, 1);
if (io_ok(stream)) {
status_msg ("Precaching...");
df = get_decoder_by_content (stream);
if (!df) {
error ("Format not supported");
io_close (stream);
status_msg ("");
}
else
status_msg ("Playing...");
}
else {
error ("Could not open URL: %s",
Expand Down
8 changes: 6 additions & 2 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static void wait_for_data ()

if (event == EV_PLIST_ADD)
event_push (&events, event, recv_item_from_srv());
else if (event == EV_PLIST_DEL)
else if (event == EV_PLIST_DEL || event == EV_STATUS_MSG)
event_push (&events, event, get_str_from_srv());
else if (event != EV_DATA)
event_push (&events, event, NULL);
Expand Down Expand Up @@ -2238,6 +2238,10 @@ static void server_event (const int event, void *data)
case EV_TAGS:
update_curr_tags (data);
break;
case EV_STATUS_MSG:
set_iface_status_ref (data);
free (data);
break;
default:
interface_message ("Unknown event: 0x%02x", event);
logit ("Unknown event 0x%02x", event);
Expand Down Expand Up @@ -3437,7 +3441,7 @@ static void get_and_handle_event ()
/* some events contail data */
if (type == EV_PLIST_ADD)
data = recv_item_from_srv ();
else if (type == EV_PLIST_DEL)
else if (type == EV_PLIST_DEL || type == EV_STATUS_MSG)
data = get_str_from_srv ();
else
data = NULL;
Expand Down
4 changes: 2 additions & 2 deletions protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ static char *make_event_packet (struct event *e, size_t *len)

*len = sizeof(e->type);

if (e->type == EV_PLIST_DEL) {
if (e->type == EV_PLIST_DEL || e->type == EV_STATUS_MSG) {
int str_len;

assert (e->data != NULL);
Expand Down Expand Up @@ -676,7 +676,7 @@ enum noblock_io_status event_send_noblock (int sock, struct event_queue *q)
plist_free_item_fields (e->data);
free (e->data);
}
else if (e->type == EV_PLIST_DEL)
else if (e->type == EV_PLIST_DEL || e->type == EV_STATUS_MSG)
free (e->data);
else if (e->data)
logit ("Unhandled event data!");
Expand Down
1 change: 1 addition & 0 deletions protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum noblock_io_status
#define EV_OPTIONS 0x0c /* the options has changed */
#define EV_SEND_PLIST 0x0d /* Request for sending the playlist. */
#define EV_TAGS 0x0e /* tags for the current file has changed. */
#define EV_STATUS_MSG 0x0f /* Followed by a status message */

/* Events caused by a client that wants to modify the playlist (see
* CMD_CLI_PLIST* commands. */
Expand Down
12 changes: 9 additions & 3 deletions server.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static void del_client (struct client *cli)
plist_free_item_fields (e->data);
free (e->data);
}
else if (e->type == EV_PLIST_DEL)
else if (e->type == EV_PLIST_DEL || e->type == EV_STATUS_MSG)
free (e->data);
event_pop (&cli->events);
}
Expand Down Expand Up @@ -329,7 +329,7 @@ static void add_event (struct client *cli, const int event, void *data)
UNLOCK (cli->events_mutex);
}

static void add_event_all (const int event, void *data)
static void add_event_all (const int event, const void *data)
{
int i;
int added = 0;
Expand All @@ -343,7 +343,8 @@ static void add_event_all (const int event, void *data)
data_copy = plist_new_item ();
plist_item_copy (data_copy, data);
}
else if (event == EV_PLIST_DEL) {
else if (event == EV_PLIST_DEL
|| event == EV_STATUS_MSG) {
data_copy = xstrdup (data);
}
else
Expand Down Expand Up @@ -1179,3 +1180,8 @@ void tags_change ()
{
add_event_all (EV_TAGS, NULL);
}

void status_msg (const char *msg)
{
add_event_all (EV_STATUS_MSG, msg);
}
1 change: 1 addition & 0 deletions server.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ void set_info_channels (const int channels);
void set_info_bitrate (const int bitrate);
void tags_change ();
void ctime_change ();
void status_msg (const char *msg);

#endif

0 comments on commit a978689

Please sign in to comment.